package org.tgcloud.group.web.controller.app;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.session.Session;
import org.tgcloud.group.service.app.NormalUserService;
import org.tgcloud.group.web.controller.dto.user.UserDTO;
import org.tgcloud.group.web.controller.req.user.UserAppSearchReq;

/**
 * @author: zhy
 * @create: 2023-08-25 09:56
 * @description: 用户相关接口
 */
@Api(tags = "用户相关接口")
@RestController
@RequestMapping("/app/user")
@EnableAutoConfiguration
public class NormalUserController extends ClientAPPBaseController{

    @Autowired
    private NormalUserService userService;

    @ApiOperation(value = "用户列表")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/userAppList")
    public APPResultMessage<Object, UserDTO> getUserAppList(@ModelAttribute("session") Session session,
                                                          @RequestBody UserAppSearchReq req) {
        return userService.getUserAppList(session.getUserId(),req);
    }

    @ApiOperation(value = "订阅")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/subscribeUserMsg")
    public APPResultMessage<Object, UserDTO> doSubscribeUserMsg(@ModelAttribute("session") Session session) {
        return userService.doSubscribeUserMsg(session.getUserId());
    }



    @ApiOperation(value = "获取用户列表")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/getUserAppListByUserType")
    public APPResultMessage<Object, UserDTO> getUserAppListByUserType(@ModelAttribute("session") Session session,
                                                            @RequestBody UserAppSearchReq req) {
        return userService.getUserAppListByUserType(session.getUserId(),req);
    }

}
